#pragma once
#include <string>
#include "windows.h"



class CTools
{
public:
	CTools();
	~CTools();

	template <typename R,typename ...Offset> R Read(uintptr_t address, const Offset ...offset)	
	{
		const size_t size = sizeof...(offset);
		const uintptr_t offsetarr[] = { offset... };

		uintptr_t value = (*(uintptr_t*)address);
		for (size_t i = 0; i < size; ++i)
		{
			value = *((uintptr_t*)(((uintptr_t)value) + ((uintptr_t)offsetarr[i])));
		}

		return (R)value;
	}
	template<typename T> T read(T t)	
	{
		try
		{
			if (IsBadReadPtr((void*)t, 4))
			{
				return 0;
			}
			return *((T*)t);
		}
		catch (...)
		{
			return 0;
		}
		
	}
	
	DWORD findMatchingCode(HANDLE hProcess, std::string markCode, DWORD memBeginAddr, DWORD memEndAddr, DWORD retAddr[], int deviation, bool isCall, bool isAll);
	
	void logA(const char* lpcszOutputString, ...);
	void logW(const wchar_t* lpcwszOutputString, ...);

private:

};

class MyString : public std::string
{
public:
	MyString(const char* str) :std::string(str) {};
	MyString(std::string str) :std::string(str) {};
	MyString() :std::string() {};

	~MyString() {};
	int toint(const char* str);
	int toint();
	template<typename S>static MyString tostr(S n)
	{
		return std::to_string(n);
	}
	
	
private:

};


